﻿using System;
using System.Collections.Generic;
using System.Web.UI.WebControls;
using ASPNETVN.PORTAL.Components.UI;
using Microsoft.Web.Testing.Light;

namespace ASPNETVN.PORTAL.Modules.DOCUMENT.Controls
{
    public partial class Spider : ItemControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ButtonProccess_Click(object sender, EventArgs e)
        {
            Components.Spider spider = new Components.Spider();
            IList<HtmlAnchorElement> results = Components.Spider.GetData(TextBoxUrl.Text, 10);
            rptResults.DataSource = results;
            rptResults.DataBind();

        }

        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            foreach (RepeaterItem item in rptResults.Items)
            {
                HyperLink link = item.FindControl("hlUrl") as HyperLink;

                //var anchor = item.DataItem as HtmlAnchorElement;
                if (link != null) 
                {
                    Components.Item document = Components.Spider.GetDataDetail(link.NavigateUrl);
                }
            }
        }
    }
}